package com.wang.action;

import com.wang.unitl.UploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletException;
import java.io.IOException;
import java.io.InputStream;

@RestController
@RequestMapping("/bbs")
public class OssAction {
    @PostMapping("/updateFile")
    private String upload(@RequestBody MultipartFile file) throws ServletException, IOException, ServletException, IOException {
        InputStream inputStream=null;
        try {
            inputStream=file.getInputStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
       String  policy=UploadUtil.policy(inputStream,file.getOriginalFilename());
        return policy;
    }
}
